#include "widget.h"
#include "ui_widget.h"
#include"QDate"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime oldtime=ui->dateTimeEdit->dateTime();//取得两个的时间数
    QDateTime newtime=ui->dateTimeEdit_2->dateTime();
    int seconds=oldtime.secsTo(newtime);
    int days=seconds/3600/24;//计算相隔天数
    int hours=seconds/3600;
    int resthour=hours%24;//除去相隔天数还差几个小时


    QString text=QString("相隔了")+QString::number(days)+QString("天 零")+QString::number(resthour)+QString("小时");
ui->label->setText(text);
}
